package com.example.myapp

import android.util.Log
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.State
import androidx.compose.runtime.mutableIntStateOf

object GlobalState {
    private val _counter = mutableIntStateOf(0)
    val counter: State<Int> = _counter

    private val _sharedText = mutableStateOf("这是共享的文本数据")
    val sharedText: State<String> = _sharedText

    fun incrementCounter() {
        _counter.intValue++
    }
    
    // 更新共享文本
    fun updateSharedText(newText: String) {
        _sharedText.value = newText
        Log.d("test", "更新共享文本：${_sharedText.value}")
    }
} 